﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Budget.DataAccess;
using Budget.DataAccess.Services;
using Budget.DataAccess.Repository;

namespace Budget.WCF
{
	// NOTE: If you change the class name "MthCategoryService" here, you must also update the reference to "MthCategoryService" in App.config.
	public class MthCategoryService : IMthCategoryService
	{
		private IMthCategoryDataService svc;

		#region IMthCategoryService Members

		public IList<MthCategory> GetAll()
		{
			if ( svc == null )
			{
				svc = new MthCategoryDataService( new BudgetRepository<MthCategory>( new BudgetDataContext() ) );
			}

			return svc.GetAll();
		}

		public IList<MthCategory> GetByMonth( int MthId )
		{
			if ( svc == null )
			{
				svc = new MthCategoryDataService( new BudgetRepository<MthCategory>( new BudgetDataContext() ) );
			}

			return svc.GetByMonth( MthId );
		}

		public void Save( MthCategory monthCategory )
		{
			if ( svc == null )
			{
				svc = new MthCategoryDataService( new BudgetRepository<MthCategory>( new BudgetDataContext() ) );
			}

			svc.Save( monthCategory );
		}

		public void Delete( int MonthCategoryId )
		{
			if ( svc == null )
			{
				svc = new MthCategoryDataService( new BudgetRepository<MthCategory>( new BudgetDataContext() ) );
			}

			svc.Delete( MonthCategoryId );
		}

		public MthCategory GetByMthCategoryId( int MthCategoryId )
		{
			if ( svc == null )
			{
				svc = new MthCategoryDataService( new BudgetRepository<MthCategory>( new BudgetDataContext() ) );
			}

			return svc.GetByMthCategoryId( MthCategoryId );
		}

		#endregion
	}
}
